// 封装本地存储
// 存储
export const setItem = (key, value) => {
  if (typeof value === 'object') {
    return localStorage.setItem(key, JSON.stringify(value))
  } else {
    return localStorage.setItem(key, value)
  }
}

// 获取
export const getItem = key => {
  let data = localStorage.getItem(key)

  try {
    return JSON.parse(data)
  } catch (error) {
    return data
  }
}
// 删除
export let removeItem = key => {
  localStorage.removeItem(key)
}
